// i18n部分的配置
// 引入语言包，注意路径
import Vue from 'vue'
import VueI18n from 'vue-i18n';
import zh_locale from 'iview/src/locale/lang/zh-CN'
import en_locale from 'iview/src/locale/lang/en-US'
import cn from '@/assets/plugin/lang/module/zh.js';
import en from '@/assets/plugin/lang/module/en.js';

// VueI18n
Vue.use(VueI18n);
Vue.locale = () => {};

// 获取系统语言
function autoLang() {
	switch (navigator.language) {
		case "en":
			return 'en'
		case "zh-CN":
			return 'zh'
		default:
			return 'zh'
	}
}

let lang = autoLang()
let i18n = new VueI18n({
	locale: lang || 'zh', // 默认选择的语言
	messages: {
		'zh': Object.assign(cn, zh_locale),
		'en': Object.assign(en, en_locale),
	}
})
export default i18n
